<template>
  <div class="app-container">
    <el-dialog title="出库" :visible.sync="dialog" :close-on-click-modal="false" close-on-press-escape width="70%">
      <template v-if="dialog">
        <wise-crud ref="wise-crud" :urls="urls" :fields="fields" :handle="handle" :filters="filters" />
      </template>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialog = false">取 消</el-button>
        <el-button type="primary" @click="dialog = false">关 闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
  import WiseCrud from '../../../../components/Crud/wiseCrud'
  import {
    dateFormat
  } from '../../../../filters'

  export default {
    name: 'UserManage',
    components: {
      WiseCrud
    },
    data() {
      return {
        entWarehouseId: null,
        dialog: false,
        handle: [],
        urls: {
          list: '/api/v1/welder-sbtx-second/warehouse-records-comb/list',
          delete: '/api/v1/welder-sbtx-second/warehouse-records-comb/remove/'
        },
        fields: [{
            label: '名称',
            prop: 'name',
            type: 'text',
            use: ['table']
          },

          {
            label: '编码',
            prop: 'coding',
            type: 'text',
            use: ['table']
          },
          {
            label: '型号',
            prop: 'model',
            type: 'text',
            use: ['table']
          },
          {
            label: '出库数量',
            prop: 'inventoryQuantity',
            type: 'text',
            use: ['table']
          },
          {
            label: '品牌',
            prop: 'brand',
            type: 'text',
            use: ['table']
          },
          {
            label: '分类',
            prop: 'dictionaryInfo.name',
            type: 'text',
            use: ['table']
          },
          {
            label: '出库项目',
            prop: 'projectInfo.name',
            type: 'text',
            use: ['table']
          },
          {
            label: '出库人员',
            type: 'render',
            use: ['table', 'view'],
            tableRender: (h, row, index) => {
              return h('div', row.warehouseOutUserInfo ? row.warehouseOutUserInfo.username : '')
            },
            viewRender: (h, item, object) => {
              return h('div', object.warehouseOutUserInfo ? object.warehouseOutUserInfo.username : '')
            }
          },
          {
            label: '出库时间',
            type: 'render',
            use: ['table', 'view'],
            tableRender: (h, row, index) => {
              return h('div', dateFormat(row.warehouseOutTime, 'YYYY-MM-DD HH:mm:ss'))
            },
            viewRender: (h, item, object) => {
              return h('div', dateFormat(object.warehouseOutTime, 'YYYY-MM-DD HH:mm:ss'))
            }
          },
          {
            label: '操作',
            type: 'handle',
            use: ['table'],
            handle: ['delete'],
            tableWidth: 80
          }
        ],
        show: true,
        flag: false
      }
    },
    computed: {
      filters() {
        return [{
          field: 'entWarehouseId',
          operator: 'EQUALS',
          value: this.entWarehouseId
        }]
      }
    },
    created() {},
    methods: {
      refreshTable() {
        if (this.flag && this.$refs['wise-crud']) {
          this.$refs['wise-crud'].handleSearch(0)
        }
      }
    }
  }
</script>

<style></style>